package com.scf.enterprise.service.serviceImpl;

import com.scf.enterprise.entity.EccontactInfor;
import com.scf.enterprise.entity.EnterpriseIfmtion;
import com.scf.enterprise.entity.LegalPerson;
import com.scf.enterprise.mapper.EnterpriseMapper;
import com.scf.enterprise.service.EnterpriseService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EnterpriseServiceImpl implements EnterpriseService {
    @Resource
    private EnterpriseMapper enterpriseMapper;

    @Override
    @Cacheable(value = "selectAll")
    public List<EnterpriseIfmtion> selectAll(EnterpriseIfmtion epinfo,int pageIndex,int pageSize) {

        List<EnterpriseIfmtion> enterpriseIfmtionList = enterpriseMapper.selectAll(epinfo,pageIndex,pageSize);
        return enterpriseIfmtionList;
    }

    @Override
    public int selectEpCount(EnterpriseIfmtion epinfo) {
        int epcount = enterpriseMapper.selectEpcount(epinfo);
        return epcount;
    }

    @Override
    public EnterpriseIfmtion selectepByid(int epid) {
        EnterpriseIfmtion enterpriseIfmtion = enterpriseMapper.selectEpByid(epid);
        return enterpriseIfmtion;
    }

    @Override
    @Caching(evict = {
            @CacheEvict(value = "selectAll",allEntries = true)
    })
    public void updateepStateByid(int epid, int epstate) {
        enterpriseMapper.updateEpById(epid, epstate);
    }

    @Override
    @Caching(evict = {
            @CacheEvict(value = "selectAll",allEntries = true)
    })
    public void updateEp(EnterpriseIfmtion epinfo) {
        enterpriseMapper.updateEp(epinfo);
    }

    @Override
    @Caching(evict = {
            @CacheEvict(value = "selectAll",allEntries = true)
    })
    public void updateLp(LegalPerson leper) {
        enterpriseMapper.updateLp(leper);
    }

    @Override
    @Caching(evict = {
            @CacheEvict(value = "selectAll",allEntries = true)
    })
    public void updateEcc(EccontactInfor ecc) {
        enterpriseMapper.updateEcc(ecc);
    }

    @Override
    @Caching(evict = {
            @CacheEvict(value = "selectAll",allEntries = true)
    })
    public void insertEpData(EnterpriseIfmtion epinfo) {
        enterpriseMapper.insertEp(epinfo);
    }

    @Override
    public void insertLpData(EnterpriseIfmtion epinfo) {
        enterpriseMapper.insertLp(epinfo);
    }

    @Override
    public void insertEccData(EnterpriseIfmtion epinfo) {
        enterpriseMapper.insertEcc(epinfo);
    }
}
